Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tooltip): add boundary padding #1065

Merged
merged 4 commits into from
Mar 9, 2021

Conversation

nickofthyme
Copy link
Collaborator

@nickofthyme nickofthyme commented Mar 9, 2021

Summary

closes #1062

Adds an artificial padding around the specified boundary element to contain tooltip within boundaries with top margins.

Screen.Recording.2021-03-09.at.09.06.08.AM.mp4

Note: This does not impact the tooltip offset for the achor.

Checklist

  • Any consumer-facing exports were added to src/index.ts (and stories only import from ../src except for test data & storybook)
  • Proper documentation or storybook story was added for features that require explanation or tutorials
  • Unit tests were updated or added to match the most common scenarios

@nickofthyme nickofthyme added enhancement New feature or request kibana cross issue Has a Kibana issue counterpart :tooltip Related to hover tooltip labels Mar 9, 2021
@nickofthyme nickofthyme requested a review from markov00 March 9, 2021 15:15
Copy link
Member

@markov00 markov00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I have tested it locally and works fine.

@@ -2221,6 +2221,8 @@ export interface TooltipInfo {
// @public
export interface TooltipPortalSettings<B = never> {
boundary?: HTMLElement | B;
// Warning: (ae-forgotten-export) The symbol "Padding" needs to be exported by the entry point index.d.ts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to expose also the Padding type?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea 8d9f3f6

@@ -138,7 +154,7 @@ const TooltipPortalComponent = ({
boundary,
// checks main axis overflow before trying to flip
altAxis: false,
padding: offset || 10,
padding: addToPadding(boundaryPadding, offset || 10),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with that offset || 10 are we saying that we always want a padding of 10 and the user cannot set 0 here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why I had 10 there. Maybe just to flip away 10px from the edge.

Anyways I removed this and only add the offset value. See 8d9f3f6

@nickofthyme nickofthyme changed the title feat(tooltip): boundary padding fix(tooltip): add boundary padding Mar 9, 2021
@codecov-io
Copy link

codecov-io commented Mar 9, 2021

Codecov Report

Merging #1065 (09c4a91) into master (27be924) will increase coverage by 0.39%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1065      +/-   ##
==========================================
+ Coverage   72.47%   72.86%   +0.39%     
==========================================
  Files         366      382      +16     
  Lines       11361    11672     +311     
  Branches     2472     2523      +51     
==========================================
+ Hits         8234     8505     +271     
- Misses       3112     3144      +32     
- Partials       15       23       +8     
Flag Coverage Δ
unittests 72.45% <50.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/components/portal/types.ts 100.00% <ø> (ø)
src/components/portal/tooltip_portal.tsx 89.61% <50.00%> (-3.55%) ⬇️
src/mocks/series/utils.ts 100.00% <0.00%> (ø)
src/mocks/geometries.ts 92.85% <0.00%> (ø)
src/mocks/specs/index.ts 100.00% <0.00%> (ø)
src/mocks/store/index.ts 100.00% <0.00%> (ø)
src/mocks/annotations/annotations.ts 66.66% <0.00%> (ø)
src/mocks/scale/index.ts 100.00% <0.00%> (ø)
src/mocks/series/series_identifiers.ts 100.00% <0.00%> (ø)
src/mocks/series/index.ts 100.00% <0.00%> (ø)
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 27be924...09c4a91. Read the comment docs.

Copy link
Contributor

@monfera monfera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@nickofthyme nickofthyme merged commit 25a247e into elastic:master Mar 9, 2021
@nickofthyme nickofthyme deleted the tooltip-boundary-padding branch March 9, 2021 20:37
nickofthyme added a commit to nickofthyme/elastic-charts that referenced this pull request Mar 9, 2021
# Conflicts:
#	api/charts.api.md
#	src/index.ts
github-actions bot pushed a commit that referenced this pull request Mar 9, 2021
## [25.0.3](v25.0.2...v25.0.3) (2021-03-09)

### Bug Fixes

* **tooltip:** add boundary padding ([#1065](#1065)) ([#1068](#1068)) ([9a44036](9a44036))
github-actions bot pushed a commit that referenced this pull request Mar 9, 2021
# [25.2.0](v25.1.1...v25.2.0) (2021-03-09)

### Bug Fixes

* **tooltip:** add boundary padding ([#1065](#1065)) ([25a247e](25a247e))

### Features

* **partition:** flame and icicle performance and tweening ([#1041](#1041)) ([a9648a4](a9648a4))
@nickofthyme
Copy link
Collaborator Author

🎉 This PR is included in version 25.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@nickofthyme nickofthyme added the released Issue released publicly label Mar 9, 2021
@@ -56,6 +57,20 @@ type PortalTooltipProps = {
chartId: string;
};

function addToPadding(padding?: Partial<Padding> | number, extra: number = 0): Padding | number | undefined {
if (!padding) return undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if padding is 0, is it OK to return undefined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I don't think this is critical but it should return just the extra value when/if padding is undefined. I'll open a pr.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@monfera fixed here #1088

AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Feb 10, 2022
# [25.2.0](elastic/elastic-charts@v25.1.1...v25.2.0) (2021-03-09)

### Bug Fixes

* **tooltip:** add boundary padding ([opensearch-project#1065](elastic/elastic-charts#1065)) ([5606eba](elastic/elastic-charts@5606eba))

### Features

* **partition:** flame and icicle performance and tweening ([opensearch-project#1041](elastic/elastic-charts#1041)) ([2ac7550](elastic/elastic-charts@2ac7550))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request kibana cross issue Has a Kibana issue counterpart released Issue released publicly :tooltip Related to hover tooltip
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tooltip boundary padding
4 participants